/**
 * Created by bethinner on 5/16/16.
 */
import React, { Component } from 'react';

import { connect } from 'react-redux'

import ItemCard from '../components/ItemCard'

export default class ListView extends Component{
    constructor(props){
        super(props);
        //if(this.props.itemType!=-1&&this.props.dataList.length==0){//非首页点击进入
        //    this.state={
        //        loading:false
        //    }
        //}else{
        //    this.state={
        //        loading:false
        //    }
        //}
    }

    componentWillReceiveProps(nextProps,nextState){
        //console.log('listview receive');
        if(this.props.dataList.get('data')!=nextProps.dataList.get('data')){
            //console.log('listview update');
            return true;
        }else{
            return false;
        }
    }
    componentWillMount(){
    }


    render(){
        return(
            <div>
                    {
                        this.props.dataList.toJS().data.map((data,index)=>{
                            return (< ItemCard key={index} itemCardData={data} index={index}
                                          itemType={this.props.itemType} clickFunc={this.props.clickFunc}/>)
                            }
                        )
                    }

            </div>

        )
    }
}

ListView.defaultProps = {
    itemType:0
};

ListView.propTypes = {
    itemType:React.PropTypes.number
};


